#include "TcpReceivceTask.h"



void Call::TcpReceiveTask::Run()
{
    while (1)
    {
        SignalBuffer buf;
        int len = m_tcpSocket.Recv<SignalBuffer>(buf);

        if (len > 0)
        {
            LOGI("recevive buf %d", buf.type);
            OnSignal(buf);
        }
        else
        {
            LOGI("socket end %s %d", m_tcpSocket.IP(), m_tcpSocket.Port());
            break;
        }
    }
}

void Call::TcpReceiveTask::OnSignal(const Call::SignalBuffer &buf)
{
    if (buf.type == Call::SignalBuffer::Type::ShoudleSpeak)
    {
        LOGI("should speak");
        CharBuf resbuf;
        std::cin >> resbuf.no;

        int len = m_tcpSocket.Send<Call::CharBuf>(resbuf);
        
        
    }
}
